package com.pussinboots.morning.sync.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pussinboots.morning.sync.dao.ProductMapper;
import com.pussinboots.morning.sync.entity.Product;
import com.pussinboots.morning.sync.service.IProductService;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by TaoShuai on 2019/9/10.
 */
@Service
@CommonsLog
@DS("master")
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
    @Autowired
    private ProductMapper productMapper;

    @Override
    public boolean updateBatchByErpId(List<Product> productList) {
        try {
            productMapper.updateBatchByErpId(productList);
            return true;
        } catch (Exception e) {
            log.error(e);
        }
        return false;
    }

    @Override
    public Integer insertBatchByErpId(List<Product> insertProductList) {
        try {
            Integer insertCount =  productMapper.insertBatchByErpId(insertProductList);
            return insertCount;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        return 0;
    }
}
